#include <stdio.h>
#include <iostream>
#include "fs.h"
#include "config.hpp"

int main(int argc, char **argv)
{

#if 1 == 1 // process load config
  // todo: load config by argument -f <config file>
  if (argc < 3 || std::string(argv[1]) != "-f")
  {
    std::cerr << "Usage: " << argv[0] << " -f <config file>" << std::endl;
    return 1;
  }

  const char *conffile = argv[2];

  Config *c = new Config(conffile);

  c->load_config();
  c->print_config();


#endif
  // create_fs();
  // sync_fs();
  mount_fs();

#if 0 != 0 // before watch
  print_fs();
#endif
#if 0 != 0
  // allocate_file("hello");
  // sync_fs();
#endif

  // supress warnning:  warning: ISO C++ forbids converting a string constant to ‘char*’
  int file = allocate_file((char *)"another");

  set_filesize(file, 1000);

  char data = 'a';

  int i;
  for (i = 0; i < 49; i++)
  {
    write_byte(0, i * 100, &data);
  }

  sync_fs();

  // print_fs();

  printf("done\n");

  delete c;

  return 0;
}
